<?php
Yii::import('application.components.dao.class.Dao');
class AuctionLiveDao extends Dao{
    
    public function attributeLabels(){
        return array(
            'title' => 'Auction Title',
            'winner_price' => 'Initial Auction Price',
            'winner_price_increment' => 'Bidding Increment'
        );
    }
    
    public function dataSource(){
        return array(
            'AuctionInfo' => array(
                'attributes'    => array(
                    'id','title','tag','short_description','description','created',
                    'start_date','end_date','winner_price_increment','winner_price','start_time','end_time','status'
                ),                
            ),
            'AuctionFee' => array(
                'attributes'    => array(
                    'value_price','auction_fee','shipping_fee','billing_fee'
                ),
            ),
            'AuctionParame' => array(
                'attributes'    => array(
                    'meta_title','meta_keywords','url','meta_description','giftcard'
                ),
            ),
            'AuctionCategoryRelations' => array(
                'attributes'    => array(
                    'category_id','category_title'
                ),
            ),
            'AuctionProductRelations' => array(
                'attributes'    => array(
                    'product_id','product_title'
                ),
            ),
            'AuctionResourceDao'   => array(
                'attributes'    => array(
                    'images'
                ),
            )
        );
    }
    public function rules(){
        return array(
           array('category_title','exist','className'=>'Category','attributeName' => 'title','message'=>'Category is not find!'),
           array('product_title','exist','className'=>'ProductInfo','attributeName' => 'title','message'=>'Product is not find!'),
           array('category_title,value_price,auction_fee,shipping_fee,billing_fee','required')  ,
           array('value_price,auction_fee,shipping_fee,billing_fee','numerical'),
           array('start_date,end_date','required','on' => 'create'),
          );
    }
    public function dataSourceRelations(){
        return array(
            'AuctionInfo'     => array(
                'AuctionFee'                    => array('part','join' => array('id' => 'auction_id')),
                'AuctionParame'                 => array('part','join' => array('id' => 'auction_id')),
                'AuctionCategoryRelations'      => array('part','join' => array('id' => 'auction_id')),
                'AuctionProductRelations'       => array('part','join' => array('id' => 'auction_id')),
                'AuctionResourceDao'            => array('part','join' => array('id' => 'auction_id')),
               
            ),
        );
    }
}